meson: fix XIAllowTouchEvents check
authorTim-Philipp Müller <tim@centricular.com>
Fri, 24 Mar 2017 11:03:56 +0000 (11:03 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 3 May 2017 14:10:55 +0000 (15:10 +0100)
Need to link against dep/lib to check for function in it. Also
misc fixes to surrounding xi-related checks.

meson.build

index 0c28c7c8755287fdd17ddc32ea28f40db73b5963..96d1fdf4841cbc843b9e7ca26d17414b2821212f 100644 (file)
@@ -266,15 +266,17 @@ if x11_enabled
     cdata.set('HAVE_XSYNC', 1)
   endif
 
-  if cc.has_function('XGetEventData', dependencies : x11_dep,
-                     prefix : '#include <X11/Xlib.h>')
+  if cc.has_function('XGetEventData', dependencies : x11_dep)
     cdata.set('HAVE_XGENERICEVENTS', 1)
   endif
 
-  if xi_dep.found() and cc.has_header('X11/extensions/XInput2.h')
+  if xi_dep.found() and cc.has_header('X11/extensions/XInput2.h', dependencies : xi_dep)
     cdata.set('XINPUT_2', 1)
+    # Note that we also check that the XIScrollClassInfo struct is defined,
+    # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(),
+    # but not the XIScrollClassInfo struct
     prefix = '#include<X11/Xlib.h>\n#include<X11/extensions/XInput2.h>'
-    if cc.has_function('XIAllowTouchEvents', prefix: prefix) and cc.has_member('XIScrollClassInfo', 'number', prefix: prefix)
+    if cc.has_function('XIAllowTouchEvents', dependencies : xi_dep) and cc.has_member('XIScrollClassInfo', 'number', prefix: prefix, dependencies : xi_dep)
       cdata.set('XINPUT_2_2', 1)
     endif
   endif